home *** CD-ROM | disk | FTP | other *** search
- Path: news.ox.ac.uk!news
- From: imc@ecs.ox.ac.uk (Ian Collier)
- Newsgroups: comp.lang.rexx
- Subject: Re: Rexx
- Date: 8 Jan 1996 15:51:19 GMT
- Organization: Oxford University Computing Laboratory
- Distribution: inet
- Message-ID: <7596.imc@comlab.ox.ac.uk>
- References: <4cf3bs$dmq@mn5.swip.net> <4cfhvv$c9k@starbase.nse.com>
- NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
- X-Local-Date: Monday, 8th January 1996 at 3:51pm GMT
-
- In article <4cfhvv$c9k@starbase.nse.com>, sberg@southwind.com wrote:
- >Not too simple, while I'm a relative newcomer to REXX I would do it this way. I
- >put in a simple command into what I got here and tested it, it worked just fine.
-
- Others have posted 'do forever/leave' solutions, but I hope you don't mind
- if I mention why the following is not a particularly good idea.
-
- >call a
-
- >loopit:
- >say "Do you want to rerun the program??"
- >Parse Upper Pull ans /* makes response case insensitive */
- > if (ans ='YES') then do
- > call a
- > end
- > else do
- > call b
- > end
-
- >a:
- >'x:\path\file.exe :params'
- >call loopit
-
- >b:
- >exit
-
- The problem is that there are lots of CALLs here without RETURNs. Now a
- CALL is usually used to do something and then return to where you were,
- as in this example.
-
- say 'Starting up'
- call count
- say 'Back here again'
- call count
- say 'Finishing'
- exit
-
- count:
- say '1 2 3 4 5 6 7 8 9 10'
- return
-
- In order to do this, the REXX interpreter must remember where it came from
- (and thus has to go back to), and that uses up a small piece of memory. In
- your example, each time the "file.exe" is run the REXX program carries out a
- "call a" and a "call loopit" without ever returning, and each of these uses
- one of those pieces of memory. Some interpreters (and I think OS/2 is one
- of them) store all these things in a particular reserved space which is
- quite small and will quite quickly abort with some error message telling
- you that there are too many nested calls (that said, you should always
- get at least 100 of them).
-
- In practice, this example is pretty harmless because as soon as you say
- "no" the program will exit and release all its storage. It's a good idea
- though to get into the habit of always returning from functions in the
- normal way.
-
- Incidentally, your program would work if you changed all the CALLs into
- SIGNALs, as a SIGNAL is a kind of go-to and the program does not contain
- anything complicated that might be disrupted by a SIGNAL. It should be
- noted, however, that SIGNAL is designated as an _abnormal_ change in the
- flow of control and so is not the best thing for this kind of program. The
- best solution, since you want a loop, is to code a loop (with 'do').
-
- Ian Collier - imc@comlab.ox.ac.uk - WWW Home Page (including REXX section):
- http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html
-
- New to this group? Answers to frequently-asked questions can be had from
- http://rexx.hursley.ibm.com/rexx/ .
-